﻿@model SlideViewModel

<div class="container-fluid" style="padding: 10px;">
    <div class="row-fluid">
        <div class="col-xs-3">
            <div class="container-fluid">
                <div class="row-fluid">
                    @{
                        var userId = DataBinder.Eval(ViewData["DataItem"], "ID");

                        var base64 = Model.Photo != null ? Convert.ToBase64String(Model.Photo) : string.Empty;
                        var imgSrc = String.Format("data:image/gif;base64,{0}", base64);
                        
                        <img alt="" id="previewImage" src="@imgSrc" width="200px" height="200px" style="width: 200px;
                            height: 200px;" />
                    }
                </div>
                @using (Html.BeginForm())
                {
                    <div class="row-fluid" style="margin-top: 5px;">
                        <div class="span12">
                            @Html.DevExpress().UploadControl(
                        settings =>
                        {
                            settings.Name = "uploadControl";
                            settings.CallbackRouteValues = new { Controller = "Slide", Action = "UploadSlideImage" };
                            settings.ControlStyle.CssClass = "editorArea";
                            settings.Width = 200;
                            settings.ShowProgressPanel = true;
                            settings.ClientSideEvents.TextChanged = "function(s, e){s.Upload(); }";
                            settings.ClientSideEvents.FileUploadComplete = "function(s,e){ if(e.callbackData != '') $('#previewImage').attr('src', e.callbackData); }";
                        }).GetHtml()
                        </div>
                    </div>
                }
            </div>
        </div>
        <div class="col-xs-9">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-xs-12">
                        <table width="100%" class="form-table">

                            <tr>
                                <td>
                                    @Html.DevExpress().LabelFor(model => model.Title).GetHtml()
                                </td>
                                <td>
                                    @Html.DevExpress().TextBoxFor(model => model.Title, settings =>
            {
                settings.Height = 30;
                settings.Width = 400;
                settings.ShowModelErrors = true;
            }).GetHtml()
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    @Html.DevExpress().LabelFor(model => model.Link).GetHtml()
                                </td>
                                <td>
                                    @Html.DevExpress().TextBoxFor(model => model.Link, settings =>
            {
                settings.Height = 30;
                settings.Width = 400;
                settings.ShowModelErrors = true;
            }).GetHtml()
                                </td>
                            </tr>

                            <tr>
                                <td>@Html.DevExpress().LabelFor(model => model.LookupID).GetHtml()
                                </td>
                                <td>
                                @Html.DevExpress().ComboBoxFor(model => model.LookupID, settings =>
                            {
                                settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
                                settings.Properties.TextField = "Value";
                                settings.Properties.ValueField = "Key";
                                settings.Properties.ValueType = typeof(Guid);
                                settings.Properties.ClientSideEvents.Init = "function(s,e){cbbTypeID=s;}";
                                settings.Height = 30;
                                settings.Width = 300;
                            }).BindList(ThinhTien.Common.LookupData.Types).Bind(Model.LookupID).GetHtml()
                                </td>
                            </tr>

                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-xs-12">
            <hr />
        </div>
    </div>
    <div class="row">
        <div class="col-xs-12">
            <button class="btn btn-primary pull-right" onclick="Cancel()" style="margin-left: 10px;">
                <i class="ico-loop4 mr5"></i>Cancel</button>
            <button class="btn btn-primary pull-right" onclick="Save();">
                <i class="ico-loop4 mr5"></i>Save</button>
        </div>
    </div>
</div>
